package com.kelvin.oocl.util;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUtil {
	
	/**
	 * 日期字符串转换为date类型数据
	 * @param dateStr
	 * @param pattern
	 * @return
	 * @throws ParseException
	 */
	public static Date strToDate(String dateStr,String pattern) throws ParseException{
		DateFormat format = new SimpleDateFormat(pattern);
		return format.parse(dateStr);
	}
	
	/**
	 * Date类型格式化
	 * @param date
	 * @param pattern
	 * @return
	 */
	public static String dateToStr(Date date,String pattern){
		DateFormat format = new SimpleDateFormat(pattern);
		return format.format(date);
	}
}
